package com.yc.vote.dao.impl;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.List;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.yc.vote.bean.Topics;

public class Text {
	public static void main(String[] args) {
		Text text = new Text();
		text.start();
	}

	private void start() {	
		try(Reader reader =Resources.getResourceAsReader("mybatis-config.xml")){
			SqlSessionFactory facotory = new SqlSessionFactoryBuilder().build(reader);
			SqlSession session = facotory.openSession();
			List<Topics> list =session.selectList("TopicsMapper.findAll");
			list.forEach(System.out::println);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
}
